package org.apache.ocean;

import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermEnum;
import org.apache.lucene.index.IndexReader;
import java.io.IOException;

/**
 *
 * @author jasonr
 */
public class CIndexSearcher extends IndexSearcher {
  public CIndexSearcher(IndexReader indexReader) {
    super(indexReader);
  }
  
  public String getMaxFieldValue(String f) throws IOException {
  	String field = f.intern();
    TermEnum termEnum = getIndexReader().terms(new Term(field, ""));
    String termval = null;
    do {
    	Term term = termEnum.term();
      if (term == null || term.field() != field) break;
      termval = term.text();
    } while (termEnum.next());
    return termval;
  }
}
